// class
//GET /game/api_chat.php?jsonpcallback=jsonp1322433612496&_=1322433632004&key=18de01c87f55b947ef61d7c6cb14df7f&lineid=132243328827&_l=en&_p=EW-DROID HTTP/1.1
//GET /game/get_cdinfo_api.php?jsonpcallback=jsonp1322488934176&_=1322488940706&key=efaec8295093025e90c5d3f63626bd48&city=3070&_l=en&_p=EW-DROID HTTP/1.1
CQuery = function() {
	
	this.objName = 'CQuery:';
	this.url = "";
	
	this.jsonpurl = '';
	this.data = '';
	this.noSessionKey = false;
	
	this.type = '';
	this.actions = [];
	this.lastext = '';
	this.cost = '';
};

// default key !! james iphone  
// CQuery.key_james = "&key=49f84472ae46aa1956ec5ab945087e7f";
// CQuery.key_greate = "&key=daaf7b06638046349f2c33e5698b8e62";

// set key & devices
// class function !! : global func for Query  
/*
CQuery.setQueryOptions = function (username, device, droid) {
			
			if ( username == 'james' 
				|| username == 'leniencsy%40gmail.com'
				|| username == 'james_PVP') {
					CQuery.device ="&_p=EW-IPHONE-EN";
					CQuery.lang = "&_l=en";
			}
			else if ( username == 'mp001' ) {
					CQuery.device ="&_p=SG-IPHONE-KR";
					CQuery.lang = "&_l=kr";
			}
			else { 
				CQuery.device = "&_p=EW-IPHONE-KR";
				CQuery.lang = "&_l=kr";
			}
		console.log(' CQuery :  ' +CQuery.device );
		debug.log(CQuery, ' CQuery :  ' +CQuery.device);
		
		//set default user key 
		// CQuery.key = CDB.getCurUserInfo().key;
		CQuery.setQueryKey(CDB.getCurUserInfo().key);
		console.log( CQuery.key );
};*/


// version 2 : support  multi type game. 
CQuery.setQueryOptions = function (us_info ) {
			
			CQuery.murl  = "http://m.emrosswar.com/";
			if ( us_info.username == 'james' 
				|| us_info.username == 'leniencsy%40gmail.com'
				|| us_info.username == 'james_PVP') {
					CQuery.device ="&_p=EW-IPHONE-EN";
					CQuery.lang = "&_l=en";
			}
			else if ( us_info.game  == 'tapsg' ) {
					CQuery.device ="&_p=SG-IPHONE-KR";
					CQuery.lang = "&_l=kr";
					
					CQuery.murl  = "http://m.tapsg.com/";
			}
			else { 
				CQuery.device = "&_p=EW-IPHONE-KR";
				CQuery.lang = "&_l=kr";
			}
		console.log(' CQuery :  ' +CQuery.device );
		debug.log(CQuery, ' CQuery :  ' +CQuery.device);
		
		//set default user key 
		// CQuery.key = CDB.getCurUserInfo().key;
		CQuery.setQueryKey(CDB.getCurUserInfo().key);
		console.log( CQuery.key );
};


CQuery.setQueryKey = function (key) {
	CQuery.key = "&key=" + key;
	console.log( ' Set:  new Key '+ CQuery.key);
};

CQuery.setServerurl = function (server) {
	CQuery.serverurl =  server;
	console.log( ' CQuery.setServerurl::  Set:  server '+ CQuery.serverurl);
};


CQuery.prototype = {

	// init ?  ..
	initialize : function() {
		var outer = this;
	},
	
	

	
	// table ... for query
	query_table : {
		favs : {
			type : 'api_fav',
			action : ['getfavnpc'],
			ext : ['favs'],
			lastext : 'none',
		},
		worldmap : {
			type : 'worldmap',
			action : ['none'],
			ext : ['coodi'],
			lastext : 'none',
		},
		sol_edu : {
			type : 'sol_edu',
			action :[ 'city'],
			ext : ['none'],
			lastext : 'none',
		},
		conscribe: {
			type: 'conscribe',
			action : ['city' , 'gen_list'],
			ext : ['extra'],
			lastext: 'none',
		},
		

		
		arena_conscribe: {
			type: 'conscribe',
			action : ['lv'],
			ext : ['none'],
			lastext: 'none',
		},
		
		arena_battle_conscribe: {
			type: 'conscribe',
			action : ['gid' ,'tgid'],
			ext : ['none'],
			lastext: 'none',
		},
		
	
		// new unified version 
		gen_conscribe_api: {
			type: 'conscribe',
			action : ['city' , 'action','gid' ,'tgid','lv' ],
			ext : ['extra'],
			lastext: 'none',
		},
			
		// H Drin
		
		hdrin_conscribe: {
			type: 'conscribe',
			action : ['city' ],
			ext : [],
			lastext: 'none',
		},
		
		hdrin_action_conscribe: {
			type: 'conscribe',
			action : ['city' , 'cons_action'],
			ext : [],
			lastext: 'none',
		},
		
		
		// later ,, merge to action_conscribe 
		rumor_conscribe: {
			type: 'conscribe',
			action : ['city' , 'cons_action'],
			ext : [],
			lastext: 'none',
		},
		
		action_conscribe: {
			type: 'conscribe',
			action : ['city' , 'cons_action'],
			ext : [],
			lastext: 'none',
		},
			
		getcit : {
			type : 'getcit',
			action : ['city'],
			ext : ['none'],
			lastext : 'none',
		},
/*
	get_cdinfo_api.php?
jsonpcallback=jsonp1321974261720&_=1321974470536&key=a0ec2950f34992bd4d5db145cfea95d3
&city=3070
&_l=en
&_p=EW-DROID

*/
		get_cdinfo : {
			type : 'get_cdinfo',
			action : ['city'],
			ext : ['none'],
			lastext : 'none',
		},
		
/*
armament_action_do_api.php?
jsonpcallback=jsonp1325133695664&_=1325133775672&key=73a526d0eac45e84efed99ae86f37408
&city=112
&act=anum
&x=19&y=12
*/
		armament_set_ta : {
			type : 'armament',
			action : ['city', 'act_anum'],
			ext : ['coodi'], // cauition ... coodi!!! 
			lastext : 'none',
		},		
		/*&city=14281
&action=do_war
&attack_type=7
&gen=185
&area=204&area_x=251
&soldier_num2=33
		*/
		armament_att : {
			type : 'armament',
			action : ['city', 'do_war'],
ext : ['at_type', 'genid', 'tainum', 'area_coodi', 'solnum'],
			lastext : 'none',
		},

		armament : {
			type : 'armament',
			action : ['city', 'do_war'],
			ext : ['coodi', 'at_type', 'tai_num'],
			lastext : 'none',
		},
		armament_att_wcost : {
			type : 'armament_action',
			action : ['city', 'do_war'],
			ext : ['at_type', 'genid', 'tainum', 'area_coodi', 'solnum'],
			lastext : 'none',
			} ,
		
		
		/*
			pvp  loot 
		*/
/*
								armament_action_do_api.php?jsonpcallback=jsonp1325133695667&_=1325133782039&key=73a526d0eac45e84efed99ae86f37408
&city=112
&attack_type=0
&gen=190
&area=19
&area_x=12
&soldier_num11=55*/

		
		armament_att_pv : {
			type : 'armament',
			action : ['city'],
			ext : ['at_type', 'genid', 'area_coodi', 'solnum'],
			lastext : 'none',
		},
		armament_action_att_wcost_pv: {
			type : 'armament_action',
			action : ['city'],
			ext : ['at_type', 'genid',  'area_coodi', 'solnum'],
			lastext : 'none',
			} ,
				
			
			/*
				message 
			*/
			
		messageapi : {
			type : 'messageapi',
			action : ['none'],
			ext : ['page'],
						lastext : 'none',
					} ,
			
		wresultlist : {
			type : 'wresultlist',
			action : ['none'],
			ext : ['page', 'listtype'],
			lastext : 'none',
			} ,
			
		wresultinfo : {
			type : 'wresultinfo',
			action : ['none'],
			ext : ['msgid'],
			lastext : 'none',
			} ,

/*
	local_market_api.php?
	jsonpcallback=jsonp1322895150032&_=1322895652255&key=e6dc55e081a118523345c1655b80c549
	&city=22336
	&_l=en&_p=EW-DROID HTTP/1.1
*/
		localmarket : {
			type : 'localmarket',
			action : ['city'],
			ext : ['none'],
			lastext : 'none',
			} ,
		
		localmarket_resput : {
			type : 'localmarket_resput',
			action : ['city' ,'reso_put'],
			ext : ['g2f','g2w', 'g2i'],
			lastext : 'none',
			} ,


		// LOGIN 
			/*
			GET /info.php?
jsonpcallback=jsonp1323389966359&_=1323389984249
&user=Greateload
&action=login
&pvp=0
&code=e7e8b613d1b08d069751171da8b0eb17fe02ee8c				// iphone kr 
		*/ 		
		login_info: {
			type: 'login_info',
			action : ['user' , 'action'],
			ext : ['pvp', 'code'],
			lastext: 'none',
		},		
/*
		
login_api.php?
jsonpcallback=jsonp1323389966360&_=1323389985557
&username=Greateload
&password=1212		
		*/
		login_api: {
			type: 'login_api',
			action : ['username' , 'password'],
			ext : [],
			lastext: 'none',
		},		

/*
			GET /game/
get_userinfo_api.php?
jsonpcallback=jsonp1323389966361&_=1323389987156
&key=b557990e3591188901cb50f1422bc0d4
&_l=kr
&_p=EW-IPHONE-KR HTTP/1.1
			
*/
		get_userinfo_api: {
			type: 'get_userinfo_api',
			action : [],
			ext : [],
			lastext: 'none',
		},		
		pvp_get_userinfo_api: {
			type: 'get_userinfo_api',
			action : [],
			ext : ['pushid'],
			lastext: 'none',
		},		


/*
	system_task_api.php?
jsonpcallback=jsonp1323389987755&_=1323389988001&key=b557990e3591188901cb50f1422bc0d4
&action=task_list
&_l=kr&_p=EW-IPHONE-KR HTTP/1.1
*/		
		system_task_api: {
			type: 'system_task_api',
			action : ['action'],
			ext : [],
			lastext: 'none',
		},		
		
		system_task_conduct: {
			type: 'system_task_api',
			action : ['action', 'id'],
			ext : [],
			lastext: 'none',
		},		
		
		
		/*
			soldier_educate_api.php?jsonpcallback=jsonp1323353477782&_=1323362536045&key=7c67cf5bf34d95dbf8c039a067a4619a
&city=22478
		*/
		soldier_educate_camp: {
			type: 'sol_edu',
			action : ['city'],
			ext : [],
			lastext: 'none',
		},		

	
	
				/*
	&city=22478
&action=soldier_educate
&soldier=2
&num=323
&gen=185 // h gid 
				*/		
	soldier_educate_train: {
			type: 'sol_edu',
			action : ['city', 'action'],
			ext : ['soldier','num', 'gen'],
			lastext: 'none',
		},		
		
	soldier_educate_disband: {
			type: 'sol_edu',
			action : ['city', 'action', 'solnum'],
			ext : [],
			lastext: 'none',
		},		


/*
	my_gen_mod_api.php?jsonpcallback=jsonp1323353477776&_=1323362198934&key=7c67cf5bf34d95dbf8c039a067a4619a
&id=87588
&action=give
&city=22478
&golds=1000
&_l=en&_p=EW-DROID HTTP/1.1
*/
	genmodapi_give: {
			type: 'genmodapi',
			action : ['hid', 'action', 'city'],
			ext : ['golds'],
			lastext: 'none',
		},		

/*
		GET /game/api_fav.php?
	jsonpcallback=jsonp1324453113056&_=1324453158117
	&key=49f84472ae46aa1956ec5ab945087e7f
	&act=addreport
	&wid=4145349
	&cat=2
	&_l=en&_p=EW-IPHONE-EN HTTP/1.1

*/
	add_fav_da: {
			type: 'api_fav',
			action : [ 'act'],
			ext : ['wid' ,'cat'],
			lastext: 'none',
		},		
		
		
		/*
study_api.php?jsonpcallback=jsonp1323353477723&_=1323353563583&key=7c67cf5bf34d95dbf8c039a067a4619a
&city=22478
&_l=en&_p=EW-DROID HTTP/1.1
		*/
	study_api: {
			type: 'study_api',
			action : [ 'city'],
			ext : [],
			lastext: 'none',
		},		
		

		
	study_mod_api: {
			type: 'study_mod_api',
			action : [ 'city'],
			ext : ['tech', 'owner'],
			lastext: 'none',
		},		
				
		
		
		
/*
building_create_task_api.php?jsonpcallback=jsonp1323353477781&_=1323362473217&key=7c67cf5bf34d95dbf8c039a067a4619a
&city=22478
&build_type=8
&_l=en&_p=EW-DROID HTTP/1.1
*/
		build_api: {
			type: 'build_api',
			action : [ 'city'],
			ext : ['buildtype'],
			lastext: 'none',
		},	
		
		
		/*
			 my item 
		*/
	
		goods_api: {
			type: 'goods_api',
			action : [ 'action' , 'type', 'page'],
			ext : [],
			lastext: 'none',
		},	
			
		goods_mod_api: {
			type: 'goods_mod_api',
			action : [ 'action' , 'city', 'id', 'num'],
			ext : [],
			lastext: 'none',
		},		
		
/*
goods_api.php?jsonpcallback=jsonp1325595647958&_=1325654454666&key=362def183bdae036dc927ebc7d02600a
&action=listupdate
&type=1
&_l=en&_p=EW-IPHONE-EN HTTP/1.1
*/

		goods_api_list: {
			type: 'goods_api',
			action : [ 'action'],
			ext : ['listtype'],
			lastext: 'none',
		},	
		
/*

goods_api.php?jsonpcallback=jsonp1325595647964&_=1325654515562&key=362def183bdae036dc927ebc7d02600a
&city=3070
&id=612505
&action=upgrade
&_l=en&_p=EW-IPHONE-EN HTTP/1.1
*/
		
		goods_api_upgrade: {
			type: 'goods_api',
			action : [ 'city', 'id', 'action'],
			ext : [],
			lastext: 'none',
		},	
		

		
		gift: {
			type: 'gift',
			action : [ 'user'],
			ext : ['code'],
			lastext: 'none',
		},			
		
		/*
GET /game/api_getcdprice.php?jsonpcallback=jsonp1326636913122&_=1326638589486
&type=1
&secs=551
*/
// ========== fast 
		api_getcdprice: {
			type: 'api_getcdprice',
			action : [ 'type', 'secs'],
			ext : [],
			lastext: 'none',
		},		
		
		goods_api_fast: {
			type: 'goods_api',
			action : [ 'ids'],
			ext : [],
			lastext: 'none',
		},		
		
	// use fast..  		
		get_cdinfo_ap_use_fasti: {
			type : 'get_cdinfo',
			action : ['city' , 'tid', 'action', 'iid' ],
			ext : [],
			lastext: 'none',
		},		
				
		sys_shop_api: {
			type: 'sys_shop_api',
			action : [ 'action', 'type', 'city', 'id'],
			ext : [],
			lastext: 'none',
		},		
		sys_shop2_api: {
			type: 'sys_shop2_api',
			action : [ 'action', 'page', 'cat' ,'num', 'id'],
			ext : [],
			lastext: 'none',
		},		
		

	/*
		 Trade 
	*/	

		safe_market_api: {
			type: 'safe_market_api',
			action : [ 'type', 'page', 'action' , 'city', 'id' ],
			ext : [],
			lastext: 'none',
		},		

		safe_goods_api: {
			type: 'safe_goods_api',
			action : [ 'action' , 'type', 'city', 'page', 'id',  'safe_num', 'price'],
			ext : [],
			lastext: 'none',
		},		

		
/*
	ally 
*/		
		api_union: {
			type: 'api_union',
			action : [ 'page' , 'name', 'id', 'tid', 'info'],
			ext : [],
			lastext: 'none',
		},			
	

		api_union_info: {
			type: 'api_union_info',
			action : [ 'op' , 'num', 'techid', 'city'],
			ext : [],
			lastext: 'none',
		},			
				
		/*
					GET /game/get_cityinfo_api.php?jsonpcallback=jsonp1325146029253&_=1325156388738
	&key=8a7f773e37c231801a667b84a0fe3ce1
	&city=100
	&action=op_pop
		*/
				
	up_durability_pv: {
			type: 'getcit',
			action : [ 'city', 'action'],
			ext : [],
			lastext: 'none',
		},		
	},
		

	setCoOdi : function(x, y) {
		
		
		this.url = this.url.replace('xxx', x);
		this.url = this.url.replace('yyy', y);

		this.data = this.data.replace('xxx', x);
		this.data = this.data.replace('yyy', y);
		
	},
	
	setCit: function(num) {
		
		if ( num !== undefined) {
			this.data = this.data.replace('&city=0000', "&city=" + num);
		} else {
			this.data = this.data.replace('&city=0000', '');
		}			
	},
	
	setConsAction: function(cons_action) {
		this.data = this.data.replace('cons_action', cons_action);
	},
	
	
	setAttType: function (atttype){
		this.url = this.url.replace('##', atttype );
		this.data = this.data.replace('##', atttype );
		if (atttype == 3) {
		// scan : remove solnum & gen 
		this.url = this.url.replace('&soldier_num--=sss', '');
		this.data = this.data.replace('&soldier_num--=sss', '');
		
		this.url = this.url.replace('&gen=ggg', '');
		this.data = this.data.replace('&gen=ggg', '');
		
		} else if ( atttype == 7 || atttype == 0) {
		// att : remove tai_num
		this.url = this.url.replace('&tai_num=ttt', '');
		this.data = this.data.replace('&tai_num=ttt', '');
		}

	},

	setHGenId: function (genid){
		if(!genid) {
		return;
		}
		this.url = this.url.replace('ggg', genid );
		this.data = this.data.replace('ggg', genid );
	},


	setSolNum: function (troops){
		if(!troops) {
		return;
		}
		var troopsdata = '';
		var trnum =0;

		if ( troops.l > 0 ) {
				troopsdata += "&soldier_num8=" + troops.l;
		}
		if ( troops.o > 0) {
				troopsdata += "&soldier_num15=" + troops.o;
		}
		if ( troops.k > 0 ) {
				troopsdata += "&soldier_num17=" + troops.k;
		}				
		if ( troops.b > 0 ) {
				troopsdata += "&soldier_num11=" + troops.b;			
		}
		if ( troops.h > 0 ) {
				troopsdata += "&soldier_num7=" + troops.h;
		}
		if ( troops.s > 0 ) {
				troopsdata += "&soldier_num2=" + troops.s;
		}

		
		this.data = this.data.replace("&soldier_num--=sss",troopsdata );
	},
	
	setTaiNum: function (tainum){
			this.url = this.url.replace('ttt', tainum );
			this.data = this.data.replace('ttt', tainum );
		},
			
	setPage: function (page){
		if ( page !== undefined) {
			this.data = this.data.replace("&page=ppp", "&page=" + page );
		} else {
			this.data = this.data.replace("&page=ppp", '');
		}	
	},
		
		setMsgid: function (msgid){
		this.url = this.url.replace('msgid', msgid);
		this.data = this.data.replace('msgid', msgid);
		},

		setListType: function (listtype){
		this.data = this.data.replace("&type=lll", "&type="+ listtype);
		},
		

	// support  '&type='  type .    
	setType: function (type){
		if ( type !== undefined ) {
			this.data = this.data.replace("&type=lll", "&type=" + type );
		} else {
			this.data = this.data.replace("&type=lll", '');
		}					
	},
		


	setCost: function (cost){
			this.url += '&' + this.endcodeFormData(cost);
			this.data += '&' + this.endcodeFormData(cost);
	},
	
	setG2f: function (g2f_amount){
		if (g2f_amount == 0 ) 
		{	// remove field 
			this.data = this.data.replace('&g2f=fffff', '' );
			return;
		}
		this.data = this.data.replace('fffff', g2f_amount );
	},
	setG2w: function (g2w_amount){
		if (g2w_amount == 0 ) 
		{	// remove field 
			this.data = this.data.replace('&g2w=wwwww', '' );
			return;
		}		
		this.data = this.data.replace('wwwww', g2w_amount );
	},
	setG2i: function (g2i_amount){
		if (g2i_amount == 0 ) 
		{	// remove field 
			this.data = this.data.replace('&g2i=iiiii', '' );
			return;
		}
		this.data = this.data.replace('iiiii', g2i_amount );
	},
			
	setLv: function (lv){
		if ( lv) {
			this.data = this.data.replace("&lv=lll", "&lv=" + lv );
		} else {
			this.data = this.data.replace("&lv=lll", '');
		}		
	},
	setGid: function (gid){
		if ( gid) {
			this.data = this.data.replace("&gid=ggggg", "&gid=" + gid );
		} else {
			this.data = this.data.replace("&gid=ggggg", '');
		}
	},
	setTGid: function (tgid){
		if ( tgid) {
			this.data = this.data.replace("&tgid=ttttt", "&tgid=" + tgid );
		} else {
			this.data = this.data.replace("&tgid=ttttt", '');
		}		
	},

	setUser: function (user){
		this.data = this.data.replace('UserID', user );
	},

	setUsername: function (username){
		this.data = this.data.replace('UserID', username );
	},
			
	setLoginAction: function (login_action){
		this.data = this.data.replace('action_name', login_action );
	},
		
	setAction: function (action){
		debug.log(this, 'action for setAction : ', action );
		if ( action) {
			this.data = this.data.replace("&action=action_name", "&action=" + action );
		} else {
			this.data = this.data.replace("&action=action_name", "" );
		}
	},
		
	
	
	setPvp: function (pvp){
		this.data = this.data.replace('normalOrPVP', pvp );
	},
		
	setCode: function (device_code){
		this.data = this.data.replace('device_code', device_code );
	},
		
	setPassword: function (password){
		this.data = this.data.replace('passWD', password );
	},
	
	/*
		train 
	*/
	setSoldier: function (soltype){
		this.data = this.data.replace('__soldier', soltype );
	},

	// support &gen=0 
	setGen: function (genid){
		if ( genid !== undefined) {
			this.data = this.data.replace("&gen=__generalid" , "&gen=" + genid );
		} else {
			// remove gen field 
			this.data = this.data.replace("&gen=__generalid" , '' );
		}
	},
		

	setExtra: function (extra){
		if (extra == 0 || extra === undefined ) 
		{	// remove field 
			this.data = this.data.replace('&extra=1', '' );
			return;
		}		
		this.data = this.data.replace('&extra=1', '&extra=' + extra);
	},
		

	setHid: function (hid){
		this.data = this.data.replace('heroid',  hid);
	},
	setGolds: function (golds){
		this.data = this.data.replace('golds_amount',  golds);
	},


/*
	add fav DA 
*/		
	setCat: function (cat){
		if ( cat ) {
			this.data = this.data.replace('&cat=cat_num', '&cat='+ cat);
		} else {
			this.data = this.data.replace('&cat=cat_num', '');
		}
	},
	
	setWid: function (wid){
		this.data = this.data.replace('&wid=wid_num', '&wid='+ wid);
	},
	
	setAct: function (actname){
		this.data = this.data.replace('&act=actname', '&act='+ actname);
	},
	
	
	setBuildType: function (buildtype){
		this.data = this.data.replace("&build_type=bldtype", "&build_type="+ buildtype);
	},
	
	/*
		 enhance 
	*/
	setId: function (id){
		if ( id !== undefined ) {
			this.data = this.data.replace('&id=idnum', "&id="+ id);
		} else {
			this.data = this.data.replace('&id=idnum', "");
		}
	},
	
	
	/*
		study 
	*/
	setTech: function (tech){
		this.data = this.data.replace("&tech=techlv", "&tech=" + tech);
	},
	
	setOwner: function (owner){
		// remove field when 0 
		if ( owner==0) { 
			this.data = this.data.replace("&owner=genid", '');
		} else {
			
			this.data = this.data.replace("&owner=genid", "&owner=" + owner);
		}
	},

	/*
		shop gem 
	*/
	setNum: function (num){
		if ( num ) {
			this.data = this.data.replace('&num=number', "&num="+ num);
		} else {
			this.data = this.data.replace('&num=number', "");
		}
	},



/*
	trade 
*/

	setSafenum: function (safe_num){
		if ( safe_num ) {
			this.data = this.data.replace("&safe_num=1", "&safe_num=" + safe_num);
		} else {
			this.data = this.data.replace("&safe_num=1", "");
		}
	},
	setPrice: function (price){
		if ( price ) {
			this.data = this.data.replace("&price=310089", "&price=" + price);
		} else {
			this.data = this.data.replace("&price=310089", "");
		}
	},


/*
	 use Fast .. 
*/
	setSecs : function (secs){
		if ( secs != undefined ) {
			this.data = this.data.replace(  "&secs=551", "&secs=" + secs);
		} else {
			this.data = this.data.replace("&secs=551", "");
		}
	},


	setIds : function (ids){
		if ( ids != undefined ) {
			this.data = this.data.replace(  "&ids=ididid", "&ids=" + ids);
		} else {
			this.data = this.data.replace("&ids=ididid", "");
		}
	},
	
	setTid : function (tid){
		if ( tid != undefined ) {
			this.data = this.data.replace(  "&tid=911200", "&tid=" + tid);
		} else {
			this.data = this.data.replace("&tid=911200", "");
		}
	},

	setIid : function (iid){
		if ( iid != undefined ) {
			this.data = this.data.replace(  "&iid=115", "&iid=" + iid);
		} else {
			this.data = this.data.replace("&iid=115", "");
		}
	},
	
	/*
		ally
	*/
	

	setName : function (name){
		if ( name != undefined ) {
			this.data = this.data.replace(  "&name=greate", "&name=" + name);
		} else {
			this.data = this.data.replace("&name=greate", "");
		}
	},

	setInfo : function (info){
		if ( info != undefined ) {
			this.data = this.data.replace(  "&info=a", "&info=" + info);
		} else {
			this.data = this.data.replace("&info=a", "");
		}
	},
	
/*
		&op=tdonate
	&techid=19
	&city=15584&
*/
	setOp : function (op){
		if ( op != undefined ) {
			this.data = this.data.replace(  "&op=tdonate", "&op=" + op);
		} else {
			this.data = this.data.replace("&op=tdonate", "");
		}
	},
	setTechid : function (techid){
		if ( techid != undefined ) {
			this.data = this.data.replace(  "&techid=19", "&techid=" + techid);
		} else {
			this.data = this.data.replace("&techid=19", "");
		}
	},
	setCity : function (city){
		if ( city != undefined ) {
			this.data = this.data.replace(  "&city=0000", "&city=" + city);
		} else {
			this.data = this.data.replace("&city=0000", "");
		}
	},		
	 
	
	// solnum 제외 .. 
	 paramTbl:   {
	 		getfavnpc : "&act=",
			act: "&act=",
			city : "&city=",
			do_war : "&action=",
			gen_list: "&action=",
			act_anum: "&act=",
			reso_put: "&reso_put=",
			lv: "&lv=",
			gid: "&gid=",
			tgid: "&tgid=",
			cons_action: "&action=",
			user: "&user=",
			action: "&action=",
			username: "&username=",
			password: "&password=",	
			hid : '&id=',
			id : '&id=',	
			
		// ext_option = 
			favs : "&cat=",
			// coodi : "&x=&y=",
			x : "&x=",
			y : "&y=",
			// area_coodi : "&area=xxx&area_x=yyy",
			area_x : "&area=",
			area_xy : "&area_x=yyy",
			at_type : "&attack_type=",
			genid: "&gen=",
			tainum : "&tai_num=",
			extra : "&extra=1",
		//	solnum: "&soldier_num--=sss",
			page: "&page=",
			listtype: "&type=",
			msgid: "&id=",
			g2f : "&g2f=",
			g2w : "&g2w=",
			g2i : "&g2i=",
			pvp: "&pvp=",
			code: "&code=",
			soldier:'&soldier=',
			num: '&num=',
			gen: '&gen=', 
			golds: '&golds=',
			wid: "&wid=",
			cat: "&cat=",
			buildtype:"&build_type=",
			
// 			pvp specific 
			pushid: "&pushid=",
			none : "",

					
		},
		
	// cannot suppport sol num ( trs obj )
	setData: function (ajaxparam) {
		var self = this;
		for ( p in ajaxparam) {
			self.data = self.data.replace( self.paramTbl [p], self.paramTbl [p] + ajaxparam[p]);
			debug.log( self, 'data: ', self.data);
		}
	},
	
	
		/*
			remove 
		*/
		

/*
	pvp specific
*/

	setPushID: function (pushid){
		this.data = this.data.replace("&pushid=pvppushid", "&pushid="+ pushid);
	},


	/*
		Getter 
	*/
	
	getType: function () {
		return this.qeury_param.type || 'Not set';
	},

	noSessionkeyType: [
		'login_info',
		'login_api',
	],
	noGamFieldType: [
		'gift',
	],
			
	makeQuery : function(type) {
		var qeury_param = this.query_table[type];
		this.qeury_param = this.query_table[type];	// for getter 
		
		if(qeury_param == undefined)
			return false;

		// check no session key type
		if ( this.noSessionkeyType.indexOf( type) >= 0 )	{
			this.noSessionKey = true;
		}
		
		// check no gam field 
		if ( this.noGamFieldType.indexOf( type) >= 0 )	{
			this.noGamField = true;
		}
		
		
		this.makeQueryStr(qeury_param);
		return true;
	},
	
/*
	makeQuery_wparam: function(type, param) {
		var query_param = this.query_table[type];

		
		if(query_param == undefined)
			return false;
		
		query_param.action = [];
		query_param.ext = [];
		
		if (param.citnum) {
			query_param.action.push('city');	
		}

		if (param.gen_list) {
			query_param.action.push('gen_list');	
		}
		
		if (param.cons_action) {
			query_param.action.push('cons_action');	
		}
		
		
		this.makeQueryStr(query_param);
		return true;
	},
	
	*/

	
	makeQueryStr : function(qeury_param) {

		var host = (this.noGamField) ? CQuery.serverurl : CQuery.serverurl + "game/";

		/*
		/?
		jsonpcallback=jsonp1321974261722&_=1321974489374&key=a0ec2950f34992bd4d5db145cfea95d3
		&page=1
		&type=3
		&_l=en
		&_p=EW-DROID*/
	/*
local_market_api.php?
jsonpcallback=jsonp1322895150033&_=1322895663627&key=e6dc55e081a118523345c1655b80c549
&city=22336
&reso_put=giveput
&g2f=7
&_l=en&_p=EW-DROID HTTP/1.1
	*/		
	
		/*
		
login_api.php?
jsonpcallback=jsonp1323389966360&_=1323389985557
&username=Greateload
&password=1212		
		*/
/*
		login_api: {
			type: 'login_api',
			action : ['username' , 'password'],
			ext : [],
			lastext: 'none',
		},		*/

/*
			GET /game/
get_userinfo_api.php?
jsonpcallback=jsonp1323389966361&_=1323389987156
&key=b557990e3591188901cb50f1422bc0d4
&_l=kr
&_p=EW-IPHONE-KR HTTP/1.1
			
*/

				/*
	&city=22478
&action=soldier_educate
&soldier=2
&num=323
&gen=185 // h gid 
				*/		
/*
	soldier_educate_train: {
			type: 'sol_edu',
			action : ['city', 'action'],
			ext : ['soldier','num', 'gen'],
			lastext: 'none',
		},		
	},*/

	
	/*

	my_gen_mod_api.php?jsonpcallback=jsonp1323353477776&_=1323362198934&key=7c67cf5bf34d95dbf8c039a067a4619a
&id=87588
&action=give
&city=22478
&golds=1000
&_l=en&_p=EW-DROID HTTP/1.1

	genmodapi_give: {
			type: 'genmodapi',
			action : ['hid', 'action', 'city'],
			ext : ['golds'],
			lastext: 'none',
		},		
	*/
	
		/*
study_api.php?jsonpcallback=jsonp1323353477723&_=1323353563583&key=7c67cf5bf34d95dbf8c039a067a4619a
&city=22478
&_l=en&_p=EW-DROID HTTP/1.1
		*/
			
/*
building_create_task_api.php?jsonpcallback=jsonp1323353477781&_=1323362473217&key=7c67cf5bf34d95dbf8c039a067a4619a
&city=22478
&build_type=8
&_l=en&_p=EW-DROID HTTP/1.1
*/


/*
goods_api.php?jsonpcallback=jsonp1325595647958&_=1325654454666&key=362def183bdae036dc927ebc7d02600a
&action=listupdate
&type=1
&_l=en&_p=EW-IPHONE-EN HTTP/1.1
*/

/*

goods_api.php?jsonpcallback=jsonp1325595647964&_=1325654515562&key=362def183bdae036dc927ebc7d02600a
&city=3070
&id=612505
&action=upgrade
&_l=en&_p=EW-IPHONE-EN HTTP/1.1
*/
					
					
/*
	GET /gift.php?jsonpcallback=jsonp1325550691617&_=1325550739615
&user=Greateload
&code=Xpp0is3
&_l=kr&_p=EW-IPHONE-KR HTTP/1.1
*/

/*

							GET /game/study_mod_api.php?jsonpcallback=jsonp1323353477767&_=1323361379226&key=7c67cf5bf34d95dbf8c039a067a4619a
&city=22478
&tech=5
&owner=87588
&_l=en&_p=EW-DROID HTTP/1.1

jsonp1323353477767({"code":0,"ret":{
"cdlist":[{"id":221306,"cdtype":2,"target":5,"owner":87588,"secs":907}]}})*/

/*
		safe_market_api.php?jsonpcallback=jsonp1326014287368&_=1326017537965&key=0314fac3e037989c062370584d3dc99b
&type=1
&page=1
*/		
		
		/*
			safe_goods_api.php?jsonpcallback=jsonp1326014287365&_=1326017475540&key=0314fac3e037989c062370584d3dc99b
&action=my_goods_safe
&city=17736
&id=75656
&safe_num=1
&price=310089				

		*/

/*

GET /game/api_union.php?jsonpcallback=jsonp1326205755618&_=1326205897076&key=a34882ecc701a8d83ccc9e9e50e747e8
&page=1
&name=greate
&id=262
&tid=1193
&info=a

*/

	/*
				api_union_info.php?jsonpcallback=jsonp1325476678152&_=1325550166741&key=362def183bdae036dc927ebc7d02600a

	*/

		var api_str = {
			api_fav : "api_fav.php?",
			worldmap : "api_world_map.php?",
			sol_edu : "soldier_educate_api.php?",
			getcit : "get_cityinfo_api.php?",
			armament : "armament_action_do_api.php?",
			conscribe : "gen_conscribe_api.php?",
			armament_action: "armament_action_task_api.php?",
			get_cdinfo: "get_cdinfo_api.php?",
			messageapi : "message_api.php?",
			wresultlist: "war_result_list_api.php?",
			wresultinfo: "war_result_info_api.php?",
			localmarket: "local_market_api.php?",
			localmarket_resput: "local_market_api.php?",
			login_info: "info.php?",
			login_api: "login_api.php?",
			get_userinfo_api: "get_userinfo_api.php?",
			system_task_api: "system_task_api.php?",
			genmodapi:'my_gen_mod_api.php?',
			study_api:'study_api.php?',
			study_mod_api: "study_mod_api.php?",
			build_api:'building_create_task_api.php?',
			goods_api:'goods_api.php?',
			goods_mod_api: "goods_mod_api.php?",
			gift:"gift.php?",
			sys_shop_api: 'sys_shop_api.php?',
			sys_shop2_api: 'sys_shop2_api.php?',
			safe_market_api: 'safe_market_api.php?',
			safe_goods_api: 'safe_goods_api.php?',
			api_getcdprice:'api_getcdprice.php?',
			api_union: 'api_union.php?',
			api_union_info: 'api_union_info.php?',
			};

		var action_obj = {
			getfavnpc : "&act=getfavnpc",
			act: "&act=actname",
			city : "&city=0000",
			do_war : "&action=do_war",
			gen_list: "&action=gen_list",
			act_anum: "&act=anum",
			reso_put: "&reso_put=giveput",
			lv: "&lv=lll",
			gid: "&gid=ggggg",
			tgid: "&tgid=ttttt",
			cons_action: "&action=cons_action",
			user: "&user=UserID",
			action: "&action=action_name",
			username: "&username=UserID",
			password: "&password=passWD",	
			hid : '&id=heroid',
			id : '&id=idnum',
			type: "&type=lll",
			favs : "&cat=2",
			coodi : "&x=xxx&y=yyy",
			area_coodi : "&area=xxx&area_x=yyy",
			at_type : "&attack_type=##",
			genid: "&gen=ggg",
			tainum : "&tai_num=ttt",
			extra : "&extra=1",
			solnum: "&soldier_num--=sss",
			page: "&page=ppp",
			listtype: "&type=lll",
			msgid: "&id=msgid",
			g2f : "&g2f=fffff",
			g2w : "&g2w=wwwww",
			g2i : "&g2i=iiiii",
			pvp: "&pvp=normalOrPVP",
			code: "&code=device_code",
			soldier:'&soldier=__soldier',
			gen: '&gen=__generalid', 
			golds: '&golds=golds_amount',
			wid: "&wid=wid_num",
			cat: "&cat=cat_num",
			buildtype:"&build_type=bldtype",
			tech:"&tech=techlv",
			owner:"&owner=genid",
			num:'&num=number',
			safe_num: "&safe_num=1",
			price: "&price=310089",
			secs:  '&secs=551',
			ids: '&ids=ididid' ,
			tid: '&tid=911200',
			iid: '&iid=115',
			name: '&name=greate',
			info: '&info=a',
			op: '&op=tdonate',
			techid: '&techid=19',

			
// 			pvp specific 
			pushid: "&pushid=pvppushid",
			none : "",
		};
		var ext_option = {
			favs : "&cat=2",
			coodi : "&x=xxx&y=yyy",
			area_coodi : "&area=xxx&area_x=yyy",
			at_type : "&attack_type=##",
			genid: "&gen=ggg",
			tainum : "&tai_num=ttt",
			extra : "&extra=1",
			solnum: "&soldier_num--=sss",
			page: "&page=ppp",
			listtype: "&type=lll",
			msgid: "&id=msgid",
			g2f : "&g2f=fffff",
			g2w : "&g2w=wwwww",
			g2i : "&g2i=iiiii",
			pvp: "&pvp=normalOrPVP",
			code: "&code=device_code",
			soldier:'&soldier=__soldier',
			gen: '&gen=__generalid', 
			golds: '&golds=golds_amount',
			wid: "&wid=wid_num",
			cat: "&cat=cat_num",
			buildtype:"&build_type=bldtype",
			tech:"&tech=techlv",
			owner:"&owner=genid",
			num:'&num=number',
// 			pvp specific 
			pushid: "&pushid=pvppushid",
			none : "",
		};

		var lastext = {
			droid : "&_p=EW-DROID",
			none : "",
		};

		//		var timestamp  = new Date().getTime().toString()

		// make action str 
		var action_str = "";
		$.each(qeury_param.action , function(i, item) {
			if(item && action_obj[item]) {
							action_str += action_obj[item];
			}
		}) ;
		
		var ext_option_str = "";
		$.each(qeury_param.ext , function(i, item) {
			if(item && ext_option[item] )
				ext_option_str += ext_option[item];
		}) ;
/*

		this.url = host + api_str[qeury_param.type] + 
			"jsonpcallback=?" 
			+ CQuery.key 
			+ action_str 
			+ ext_option_str
			+ CQuery.lang
			+ CQuery.device;		
		*/

		
		// joson p  ... type 
		// check login exceptino 
		if ( qeury_param.type == 'login_info' || qeury_param.type == 'gift') {
			host = CQuery.murl;
			// host = "http://m.emrosswar.com/";
		}
		
		this.jsonpurl = host +  api_str[qeury_param.type] + 
			"jsonpcallback=?" ;
			
		this.data = ( this.noSessionKey ? action_str.substring(1) : CQuery.key.substring(1) + action_str ) 
			+ ext_option_str
			+ CQuery.lang
			+ CQuery.device; 

		/*
			
				// armament 筌ｌ꼪?占쏙옙?占쎌굲  & armament_cost
				if(qeury_param.type.match("armament")) {
					this.url = host + api_str[qeury_param.type] + "jsonpcallback=?" + CQuery.key + action_obj[qeury_param.action[0]]// city
					+ action_obj[qeury_param.action[1]]// do war
					+ ext_option[qeury_param.ext[0]]// coodi
					+ ext_option[qeury_param.ext[1]]// at type
					+ ext_option[qeury_param.ext[2]]// tai num
					+ "&_l=en" + lastext[qeury_param.lastext];
		
					if(qeury_param.type == "armament_cost") {
						this.url += '&' + this.endcodeFormData(qeury_param.cost);
					}
				} else {
					// normal query
		
					this.url = host + api_str[qeury_param.type] + "jsonpcallback=?" + CQuery.key + action_obj[qeury_param.action] + ext_option[qeury_param.ext] + "&_l=en" + lastext[qeury_param.lastext];
				}
		*/
		
		// console.log(' make Q url : '+ this.url);
		// return this.url;
	},
	endcodeFormData : function(data) {
		var pairs = [];
		var regexp = /%20/g;

		for(var name in data ) {
			var value = data[name].toString();
			var pair = name + "=" + value;
			pairs.push(pair);
		}

		return pairs.join('&');
	},
	// ?占쎌룞??type ?占쎌룞?占썲뜝?占쎌삕 ?占쎌룞?占썲뜝?占쎌삕?占쎌뙏?占쎌삕 ?占쎌떦?占쎌삕 action, ext ?占쎌룞???占쎌룞?占썲뜝?占쎌삕 ?占쎌떎?占쎌삕?占쎌룞?占썲뜝占쏀솗?占쎌룞??
	validate : function() {
		//			switch( this.type)
		//					},
		return true;
	},
	dump : function() {
		//em.util.print_obj(this);
		console.info(' Query dump : ' , this);
	},
	print:	function() {
		if ( em.debug.query_print ) {
		// console.log( 'Query    url: ' + this.url);
		console.log( 'Query    url: ' + this.jsonpurl + '&' + this.data);
		}
	},
};

function trans(str) {
	//	document.getElementById("unicode").value = replaceAll(escape(str),"%","\\");
	return replaceAll(escape(str), "%", "\\");
}

function detrans(str) {
	//	var str = document.getElementById("unicode2").value;
	//	document.getElementById("hangul2").value = unescape(replaceAll(str,"\\","%"));
	return unescape(replaceAll(str, "\\", "%"));
}

function replaceAll(strTemp, strValue1, strValue2) {
	while(1) {
		if(strTemp.indexOf(strValue1) != -1)
			strTemp = strTemp.replace(strValue1, strValue2);
		else
			break;
	}
	return strTemp;
}

// Expert Info (Chat/Sequence):
// GET /game/api_world_map.php?jsonpcallback=jsonp1322034289959\
// &_=1322034437410
// &key=3badb54bda7e38920062ad493d1c9944
// &x=224&y=250
// &_l=en HTTP/1.1\r\n

// 222/ 252 : 3 star 4
// 224/ 253  :4 start 29

// /soldier_educate_api.php?jsonpcallback=jsonp1321974261717&_=1321974450455
//&key=a0ec2950f34992bd4d5db145cfea95d3
//&city=3070&_l=en&_p=EW-DROID

/*
 2: sp
 8 : lanu
 15 : ov
 17: k
 jsonp1321974261717(
 {"code":0,
 "ret":
 {"soldiers":
 [[1,0,1],[2,121,1],[3,0,1],[4,0,1],[5,0,1],[6,0,1],[7,0,1],[8,1528,1],[9,0,1],[10,12,1],[11,0,1],[12,0,1],[13,0,1],[14,0,1],[15,2077,1],[16,0,1],[17,2699,1],[18,1,1]],
 "space":6562,"head":8356,"def":1,"next":[0,0],"f":-38261}})
 */

/*
 armament_action_do_api.php?
 jsonpcallback=jsonp1321974261718&_=1321974460167&key=a0ec2950f34992bd4d5db145cfea95d3
 &city=3070
 &action=do_war
 &attack_type=3
 &tai_num=3
 &area=184&area_x=53
 &_l=en
 &_p=EW-DROID

 jsonp1321974261718(
 {"code":0,
 "ret":
 {"carry":180,"cost_food":180,"cost_wood":0,"cost_iron":0,"cost_gold":0,"distance":2040,"travel_sec":0}})
 */

/*

 get_cityinfo_api.php?
 jsonpcallback=jsonp1321974267349&_=1321974460196&key=a0ec2950f34992bd4d5db145cfea95d3
 &city=3070
 &_l=en
 &_p=EW-DROID

 2 : remain area
 192 : area
 484741,21213527,2915768,21213527,220137,21213527,1075887,21213527,  : resource  cur / max
 9652,9644, : popul
 5,5,5,29, :  farm
 18,26,24,22,13,24,18,  : structure   town, bar, wall, arena, storage,  research, fucility

 jsonp1321974267349(
 {"code":0,
 "ret":
 {"city":
 [2,193,
 484741,21213527,2915768,21213527,220137,21213527,1075887,21213527, //9
 9652,9644, 	//11
 5,5,5,29,		//15
 18,26,24,22,13,24,18,   // 22
 [{"id":39545,"itemid":166,"secs":118075}, //23
 {"id":40536,"itemid":166,"secs":462108},
 {"id":40819,"itemid":120,"secs":45057}]
 ,0],
 "grade":62,"money":0}
 }
 )
 */

/*
 //
 armament_action_task_api.php?
 jsonpcallback=jsonp1321974261719&_=1321974468658&key=a0ec2950f34992bd4d5db145cfea95d3
 &city=3070
 &action=war_task
 &attack_type=3&tai_num=3
 &area=184&area_x=53
 &_l=en
 &_p=EW-DROID
 &carry=180&cost_food=180&cost_wood=0&cost_iron=0&cost_gold=0&distance=2040&travel_sec=0

 jsonp1321974261719(
 {"code":0,
 "ret":
 {"cd":
 [{"id":3281779,"cdtype":4,"target":3,"owner":0,"secs":0,"ret":0,"ext":"184\/53"}]
 }
 }
 )

 */

/*
 get_cdinfo_api.php?
 jsonpcallback=jsonp1321974261720&_=1321974470536&key=a0ec2950f34992bd4d5db145cfea95d3
 &city=3070
 &_l=en
 &_p=EW-DROID

 jsonp1321974261720(
 {"code":0,
 "ret":
 {"cdlist":
 [
 {"id":757395,"cdtype":1,"target":4,"owner":0,"secs":170134},
 {"id":780811,"cdtype":1,"target":9,"owner":0,"secs":504194},
 {"id":805491,"cdtype":0,"target":5,"owner":0,"secs":5220},
 {"id":206987,"cdtype":2,"target":5,"owner":26106,"secs":58628}],
 "grade":62,"money":0}}
 )
 */

/*
 message_api.php?
 jsonpcallback=jsonp1321974261721&_=1321974484078&key=a0ec2950f34992bd4d5db145cfea95d3
 &page=1
 &_l=en
 &_p=EW-DROID

 jsonp1321974261721(
 {"code":0,
 "ret":
 {"mail":
 [
 {"id":"473273","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321968210,"new":1},{"id":"471036","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09\uc2dc\uac04 \u2605\u2605","time":1321925649,"new":1},
 {"id":"470279","sender":"sys","title":"Famine happens in Castle [185\/53]!","time":1321913471,"new":0},{"id":"469881","sender":"sys","title":"NO Food in Castle [185\/53]!","time":1321889675,"new":1},{"id":"469772","sender":"sys","title":"Eliminated by [Led] adam in PVP","time":1321886003,"new":1},{"id":"468104","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321842417,"new":1},
 {"id":"468103","sender":"\uae40\uc120\uc9c4","title":"24\uc77c \ubaa9\uc694\uc77c 18\uc2dc \ud734\uc804\ud574\uc81c","time":1321838344,"new":0},{"id":"467545","sender":"sys","title":"[185\/53]\uc131 \ub0b4\uc5d0 \uc2dd\ub7c9\uc774 \uc5c6\uc2b5\ub2c8\ub2e4!","time":1321829813,"new":1},{"id":"466090","sender":"sys","title":"Resource Colony 4\/72 is expired","time":1321791198,"new":1},{"id":"467552","sender":"\ud751\uc778","title":"\ud751\uc778\ub18d\uc7a5 \uc0ac\uc6a9\ubc29\ubc95","time":1321762518,"new":0},
 {"id":"467551","sender":"\ud751\uc778","title":"\ud751\uc778\ub18d\uc7a5 \uc0ac\uc6a9\ubc29\ubc95","time":1321762510,"new":0},{"id":"467550","sender":"\uae40\uc120\uc9c4","title":"\uc0ac\uce6d\uc8fc\uc758","time":1321762288,"new":0},{"id":"467549","sender":"\ud751\uc778","title":"\uc8fc \ud751\uc778\ub18d\uc7a5\uac1c\uc5c5 \uc0ac\uc6a9\ubc29\ubc95","time":1321762278,"new":0},{"id":"467548","sender":"\ud751\uc778","title":"(\uc8fc) \ud751\uc778\ub18d\uc7a5 \uac1c\uc5c5","time":1321762183,"new":0},{"id":"467547","sender":"\ud751\uc778","title":"\ub2e4\ub4e4 \uc218\uc1a1\ud301 \ub2e4\uc2dc-\ucd5c\uc885\uc801","time":1321759625,"new":0},{"id":"467546","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321755594,"new":1},{"id":"462487","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321680488,"new":1},{"id":"462486","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321677413,"new":1},{"id":"462485","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321675795,"new":1},
 {"id":"462484","sender":"sys","title":"\u2605\u2605 \uacc4\uc88c\uc774\uccb4 \uc82c \uad6c\ub9e4 \ubc29\ubc95 \/ \uc9c0\uae09 \uc2dc\uac04 \u2605\u2605","time":1321675492,"new":1}
 ],
 "max":2}})
 */

/*

 /war_result_list_api.php?
 jsonpcallback=jsonp1321974261722&_=1321974489374&key=a0ec2950f34992bd4d5db145cfea95d3
 &page=1
 &type=3
 &_l=en
 &_p=EW-DROID

 jsonp1321974261722(
 {"code":0,
 "ret":
 {"war":
 [
 {"id":3276196, // id !!
 "type":3,"aid":3074,"did":0,"aname":"james!!","dname":null,
 "acid":3070,"dcid":0,
 "acity":"\ucc9c\uc0c1\uc131",
 "dcity":"\ucc9c\uc0c1\uc131",
 "ax":185,"ay":53,

 "dx":184,"dy":53, // coodi

 "flag":1,
 "time":1321974150,
 "new":1}
 ],"max":1}})
 */

/*

 war_result_info_api.php?
 jsonpcallback=jsonp1321974261723&_=1321974497945&key=a0ec2950f34992bd4d5db145cfea95d3
 &id=3276196		// id
 &_l=en
 &_p=EW-DROID

 // Horror(694)
 jsonp1321974261723({
 "code":0,
 "ret":
 {
 "war_report":null,
 "scout_report":
 {"flag":0,
 "result":
 "<b>[Hero]<\/b><br\/>ChaosSlave (Lvl.3)<br\/><br\/><b>[Troops]<\/b><br\/>Horror(694)<br>Attack(15)&nbsp;&nbsp;Defense(8)&nbsp;&nbsp;Health(80)<br><br>"},
 "other_report":null}})
 */

/*
 api_fav.php?
 jsonpcallback=jsonp1321974261724&_=1321974513522&key=a0ec2950f34992bd4d5db145cfea95d3
 &act=addreport
 &wid=3276196&cat=2
 &_l=en&_p=EW-DROID

 jsonp1321974261757(
 {"code":0,"ret":""}
 )
 */




/*
	 ====== login 
*/

/*
 GET /game/get_userinfo_api.php?
 jsonpcallback=jsonp1324453085067&_=1324453110691
 &key=49f84472ae46aa1956ec5ab945087e7f
 &pushid=%3C258ec43a+015cfd9c+4681d00b+b484e756+f58030c7+8391315a+eadcd107+1b96404c%3E
 &_l=en&_p=EW-IPHONE-EN HTTP/1.1
 
 jsonp1324453085067(
 	{"code":0,"ret":
 	{"user":
 	{"id":3074,"nick":"james!!","nationid":2,"level":65,"money":53,"guild":"\uba85\uc608","guildid":103,
 	"gpower":5,"gflag":127,"protection":0,"p_end":1315560654,"status":0,
 	"city":[{"id":3070,"name":"\ucc9c\uc0c1\uc131","landtype":3,"x":185,"y":53},
 	{"id":14798,"name":"\ucc9c\uc911\uc131","landtype":1,"x":184,"y":54},
 	{"id":15072,"name":"\ucc9c\ud558\uc131","landtype":4,"x":188,"y":56},
 	{"id":15584,"name":"\ucc9c\ud654\uc131","landtype":3,"x":188,"y":50},
 	{"id":17169,"name":"\ucc9c\ud669\uc131","landtype":5,"x":184,"y":51},{"id":21909,"name":"\ucc9c\uacf5\uc131","landtype":3,"x":182,"y":50}],"conq":[0,0,"",5],"gift":[{"id":168,"msg":"","s":0}],"pvp":46},"events":[{"id":1,"icon":"gem.jpg","name":"Hardworking Lord Must be Rewarded! [6\/7 days]","desc":"<b>Daily Gift<\/b> will be issued everyday after login. And Lords who login for 7 consecutive days will further win <b>Bless of Building I<\/b> for free!"},{"id":2,"icon":"0.png","name":"Level Gap Protection for Active Lord","desc":"You are protected from lords that are 10+ levels higher, unless you attack first. This buff will NOT work when being offline for 24+ hours."}],
 	"status":{"invite":1,"ver":0.9,"vs":1.25,"vr":0.5,"ce":1,"he":1}}})
 
*/	
